package cn.elwy.rcp.core.model.ui;

import cn.elwy.rcp.core.model.ui.progress.ProgressMonitor;

@SuppressWarnings("unchecked")
public class InputModel implements DataModel {

  protected Object input;
  protected Condition condition;
  protected ProgressMonitor monitor;

  public InputModel() {
  }

  public InputModel(Object input) {
    this.input = input;
  }

  public InputModel(Condition condition) {
    this.condition = condition;
  }

  @Override
  public final <T> T getInput() {
    if (input != null) {
      return (T) input;
    } else {
      return (T) query();
    }
  }

  public void setInput(Object input) {
    this.input = input;
  }

  @Override
  public Condition getCondition() {
    return condition;
  }

  @Override
  public void setCondition(Condition condition) {
    this.condition = condition;
  }

  @Override
  public ProgressMonitor getProgressMonitor() {
    return monitor;
  }

  public void setProgressMonitor(ProgressMonitor monitor) {
    this.monitor = monitor;
  }

  protected Object query() {
    return null;
  }

}